package com.sky.server;

import com.sky.constant.RedisConstant;
import jakarta.annotation.Resource;
import org.redisson.api.RTopic;
import org.redisson.api.RedissonClient;
import org.redisson.codec.SerializationCodec;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

/**
 * @author linzp
 * @version 1.0.0
 * CreateDate 2021/1/29 9:20
 */
@Service
public class PublishService {
    @Resource
    private RedissonClient redissonClient ;

    public void sendMsg(String message){
        try {
            RTopic clientTopic = redissonClient.getTopic(RedisConstant.REDISSON_TOPIC,new SerializationCodec());
            clientTopic.publishAsync(message);
        } catch (Exception e) {
            System.out.println("消息发送失败 ~~");
        }
    }
}
